package com.flxz.forum.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flxz.common.annotation.Log;
import com.flxz.common.core.controller.BaseController;
import com.flxz.common.core.domain.AjaxResult;
import com.flxz.common.enums.BusinessType;
import com.flxz.forum.domain.ForumReport;
import com.flxz.forum.service.IForumReportService;
import com.flxz.common.utils.poi.ExcelUtil;
import com.flxz.common.core.page.TableDataInfo;

/**
 * 讨论举报Controller
 * 
 * @author fl
 * @date 2025-09-14
 */
@RestController
@RequestMapping("/forum/report")
public class ForumReportController extends BaseController
{
    @Autowired
    private IForumReportService forumReportService;

    /**
     * 查询讨论举报列表
     */
    @PreAuthorize("@ss.hasPermi('forum:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(ForumReport forumReport)
    {
        startPage();
        List<ForumReport> list = forumReportService.selectForumReportList(forumReport);
        return getDataTable(list);
    }

    /**
     * 导出讨论举报列表
     */
    @PreAuthorize("@ss.hasPermi('forum:report:export')")
    @Log(title = "讨论举报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ForumReport forumReport)
    {
        List<ForumReport> list = forumReportService.selectForumReportList(forumReport);
        ExcelUtil<ForumReport> util = new ExcelUtil<ForumReport>(ForumReport.class);
        util.exportExcel(response, list, "讨论举报数据");
    }

    /**
     * 获取讨论举报详细信息
     */
    @PreAuthorize("@ss.hasPermi('forum:report:query')")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return success(forumReportService.selectForumReportByReportId(reportId));
    }

    /**
     * 新增讨论举报
     */
    @PreAuthorize("@ss.hasPermi('forum:report:add')")
    @Log(title = "讨论举报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ForumReport forumReport)
    {
        return toAjax(forumReportService.insertForumReport(forumReport));
    }

    /**
     * 修改讨论举报
     */
    @PreAuthorize("@ss.hasPermi('forum:report:edit')")
    @Log(title = "讨论举报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ForumReport forumReport)
    {
        return toAjax(forumReportService.updateForumReport(forumReport));
    }

    /**
     * 删除讨论举报
     */
    @PreAuthorize("@ss.hasPermi('forum:report:remove')")
    @Log(title = "讨论举报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(forumReportService.deleteForumReportByReportIds(reportIds));
    }
}
